﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMIS.DAL
{
    public class Recommend
    {
        private Model.ThesisDB db = new Model.ThesisDB();
        /// <summary>
        /// 根据ID号从数据库中查找对应的论文推优信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public string Search(Guid guid)
        {
            string opinion = (from r in db.Recommend
                              where r.ID == guid
                              select r.Opinion).FirstOrDefault();
            return opinion;
        }
        /// <summary>
        /// 更新数据库中论文推优表信息
        /// </summary>
        /// <param name="rec"></param>
        public void Update(Model.Recommend recommend)
        {
            Model.Recommend rec = db.Recommend.Single(e => e.ID == recommend.ID);
            rec.Opinion = recommend.Opinion;
            db.SubmitChanges();
        }

        public void Insert(Model.Recommend recommend)
        {
            db.Recommend.InsertOnSubmit(recommend);
            db.SubmitChanges();
        }
    }
}
